<?php
/**
 * ARRAY functions
 *
 * @version 0.2a
 */
 
// No direct access
defined( "__DEENZO__" ) or die( "deenzo$" ); 

// Sorts an array and return value quickly
function asrt( $array ) {

    sort( $array ); return $array;
}

function astr( $array, $args = "" ) {
    
    /* Parse ARGS */
    eval( ARGL );
    
    // Objects are not supported
    if ( is_object( $array ) ) 
        return "'OBJECT'";
    
	if ( !$p ) $s = "array(";

	foreach ( $array as $k => $v ) {
		
		if ( is_string( $k ) and $p )
			$s .= "'$k' => ";
		
		/* V is a non-supported Object */
		if ( is_object ( $v ) ) 
		    $s .= "'OBJECT', ";
		
		/* V is an array, recursive callback */
		elseif ( is_array  ( $v ) ) 
		    $s .= astr( $v ) . ", ";
		
		/* V is string */
		elseif ( is_string ( $v ) ) 
		    $s .= "'" . str_replace( "'", "\'", $v) . "', ";
		
		/* V is numeric */
		elseif ( is_numeric( $v ) ) 
		    $s .= "$v, ";
		
		/* V is a boolean */
		elseif ( is_bool   ( $v ) ) 
		    $s .= ( $v ) ? "true, " : "false, ";
		
		/* Otherwise, V is NULL */
		else                        
		    $s .= "NULL, ";
	}
	
	if ( !$p ) 
	    return substr( $s, 0, strlen( $s ) - 2) . ")";
	else       
	    return substr( $s, 0, strlen( $s ) - 2);
}